package top.songxs.yygh.hosp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.songxs.yygh.common.result.R;
import top.songxs.yygh.hosp.service.HospitalService;
import top.songxs.yygh.model.hosp.Hospital;
import top.songxs.yygh.vo.hosp.HospitalQueryVo;

import java.util.Map;

// 给后端管理系统使用的controller
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    HospitalService hospitalService;



    @GetMapping("{pageNum}/{pageSize}")
    public R index(@PathVariable Integer pageNum, @PathVariable Integer pageSize, HospitalQueryVo vo) {

        Page<Hospital> pages = hospitalService.selectPage(pageNum, pageSize, vo);
        return R.ok().data("pages", pages);
    }



    @GetMapping("updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable String id, @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return R.ok();
    }

    //查询医院详情
    @GetMapping("show/{id}")
    public R showDetail(@PathVariable String id) {

        //hospital + bookingRule
        Map<String, Object> map = hospitalService.showDetail(id);
        return R.ok().data(map);
    }


}
